import Vue from 'vue'
import App from './App'
import store from './store'
import router from './router'
import * as http from './api'

// import mock from './mock'

import '@/icons'
import '@/permission'
import './ElementUI.js'
import '@/styles/index.scss'
import 'normalize.css/normalize.css'
import HwComponents from './components'

import { getOss } from '@/utils/alioss'

import _ from 'lodash'
import moment from 'moment'

//  全局过滤器 时间戳
Vue.filter('dateformat', function (dataStr, pattern = 'YYYY-MM-DD') {
  if (dataStr) {
    return moment(dataStr).format(pattern)
  } else {
    return dataStr
  }
})

// router.beforeEach((to, from, next) => {
//   // tabs重置选中currentKey
//   let toPath = to.path?.split('/')
//   let fromPath = from.path?.split('/')
//   if (toPath[2] !== fromPath[2]) {
//     store.commit('base/SET_TABS_TYPE', { value: '' })
//   }
//   next()
// })

// 从本地存储获取plicy
// store.dispatch('user/resetPolicy')

import { handleConfirm } from '@/hooks' // confirm弹窗
import { VueJsonp } from 'vue-jsonp' // jsonp跨域

Vue.prototype.$lodash = _ // lodash库
Vue.prototype.$moment = moment // moment库
Vue.prototype.$http = http // 将api挂载到vue原型上
Vue.prototype.$handleConfirm = handleConfirm

// Vue.prototype.$httpMock = mock // 将api挂载到vue原型上

Vue.config.productionTip = false

Vue.use(VueJsonp) // jsonp跨域
Vue.use(HwComponents) // components下的所有组件

getOss()

new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
